package com.goods.controller.business;

import com.goods.business.service.OutStockServices;
import com.goods.common.response.ResponseBean;
import com.goods.common.vo.business.InStockVO;
import com.goods.common.vo.business.OutStockDetailVO;
import com.goods.common.vo.business.OutStockVO;
import com.goods.common.vo.system.PageVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author ：MJS
 * @date ：Created in 2021/6/10  9:58
 * @description：TODO
 */
@Api
@RestController
@RequestMapping("/business/outStock")
public class OutStockController {
    @Autowired
    private OutStockServices outStockServices;
    //加载出库表格数据
    @ApiOperation(value = "出库信息列表", notes = "模糊查询出库信息列表")
    @GetMapping("/findOutStockList")
    public ResponseBean<PageVO<OutStockVO>> findOutStockList(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                                           @RequestParam(value = "pageSize",defaultValue = "6") Integer pageSize,
                                                           OutStockVO outStockVO){
        PageVO<OutStockVO>outStockList=outStockServices.findOutStockList(pageNum,pageSize,outStockVO);
        return ResponseBean.success(outStockList);
    }
    //查询发放明细
    @ApiOperation(value = "发放信息列表中的明细", notes = "查询发放信息选中的明细信息")
    @GetMapping("/detail/{id}")
    public ResponseBean<OutStockDetailVO> detail(@PathVariable Long id, @RequestParam Integer pageNum){
        OutStockDetailVO outStockDetailVO=outStockServices.detail(id,pageNum);
        return ResponseBean.success(outStockDetailVO);
    }
    //移入回收站
    @ApiOperation(value = "移入回收站", notes = "数据移入回收站")
    @PutMapping("/remove/{id}")
    public ResponseBean remove(@PathVariable Long id){
        outStockServices.remove(id);
        return ResponseBean.success();
    }
    //从回收站恢复
    @ApiOperation(value = "从回收站恢复", notes = "数据移出回收站")
    @PutMapping("/back/{id}")
    public ResponseBean back(@PathVariable Long id){
        outStockServices.back(id);
        return ResponseBean.success();
    }

    //删除发放记录
    @ApiOperation(value = "从回收站删除", notes = "删除物资")
    @DeleteMapping("/delete/{id}")
    public ResponseBean delete(@PathVariable Long id){
        outStockServices.delete(id);
        return ResponseBean.success();
    }

    //添加发放单
    @ApiOperation(value = "添加入库单", notes = "入库单的添加")
    @PostMapping("/addOutStock")
    public ResponseBean addOutStock( @RequestBody OutStockVO outStockVO){
        outStockServices.addOutStock(outStockVO);
        return ResponseBean.success();
    }
    //出库单审核
    @ApiOperation(value = "出库单审核", notes = "出库单审核")
    @PutMapping("/publish/{id}")
    public ResponseBean publish(@PathVariable Long id){
        outStockServices.publish(id);
        return ResponseBean.success();
    }
}
